package com.avic.map.common.convertor;


import com.avic.map.common.model.enums.MapDataStatusEnums;
import com.avic.map.controller.info.MapCarResourceListInfo;
import com.avic.map.dal.model.CarResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 地图船舶资源对象转换器
 *
 * @author huangsheng
 */
public class MapCarResourceConvertor {


    public static List<MapCarResourceListInfo> carResourceListToMapCarResourceListInfoList(List<CarResource> carResourceList) {
        if (null != carResourceList && carResourceList.size() > 0) {
            List<MapCarResourceListInfo> mapCarResourceListInfos = new ArrayList<>(carResourceList.size());
            carResourceList.forEach(carResource -> {
                MapCarResourceListInfo mapCarResourceListInfo = new MapCarResourceListInfo();
                mapCarResourceListInfo.setCarName(carResource.getCarType());
                mapCarResourceListInfo.setCarNumber(carResource.getCarNumber());
                mapCarResourceListInfo.setCarState(carResource.getCarState());
                mapCarResourceListInfo.setFleetName(carResource.getFleetName());

                MapDataStatusEnums mapDataStatusEnums = MapDataStatusEnums.getMapDataStatusEnumsByType(carResource.getCarState());
                mapCarResourceListInfo.setCarStateDescribe(null != mapDataStatusEnums ? mapDataStatusEnums.getMapStateValue() : StringUtils.EMPTY);
                mapCarResourceListInfos.add(mapCarResourceListInfo);
            });
            return mapCarResourceListInfos;
        }
        return new ArrayList<>();
    }
}
